





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.relay.testing &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
        <script src="../../../../_static/jquery.js"></script>
        <script src="../../../../_static/underscore.js"></script>
        <script src="../../../../_static/doctools.js"></script>
        <script src="../../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../../search.html" />
    <link rel="next" title="tvm.autotvm" href="../autotvm.html" />
    <link rel="prev" title="tvm.relay.dataflow_pattern" href="dataflow_pattern.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../../index.html">
          

          
            
            <img src="../../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="../error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../target.html">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="../driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="../auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="../micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="../contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="../graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="../index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.relay.testing</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../../_sources/reference/api/python/relay/testing.rst.txt" rel="nofollow"> <img src="../../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.relay.testing">
<span id="tvm-relay-testing"></span><h1>tvm.relay.testing<a class="headerlink" href="#module-tvm.relay.testing" title="永久链接至标题">¶</a></h1>
<p>Utilities for testing and benchmarks</p>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Prelude</span></code>([mod])</p></td>
<td><p>Contains standard definitions.</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">enabled_targets</span></code>()</p></td>
<td><p>Get all enabled targets with associated devices.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">create_workload</span></code>(net[, initializer, seed])</p></td>
<td><p>Helper function to create benchmark image classification workload.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">count</span></code>(prelude, n)</p></td>
<td><p>Takes a ConstructorValue corresponding to a nat ADT and converts it into a Python integer.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">make_nat_value</span></code>(prelude, n)</p></td>
<td><p>The inverse of count(): Given a non-negative Python integer, constructs a ConstructorValue representing that value as a nat.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">make_nat_expr</span></code>(prelude, n)</p></td>
<td><p>Given a non-negative Python integer, constructs a Python expression representing that integer’s value as a nat.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">to_python</span></code>(expr[, mod, target])</p></td>
<td><p>Converts the given Relay expression into a Python script (as a Python AST object).</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">run_as_python</span></code>(expr[, mod, target])</p></td>
<td><p>Converts the given Relay expression into a Python script and executes it.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">gradient</span></code>(expr[, mod, mode])</p></td>
<td><p>Transform the input function, returning a function that calculate the original result, paired with gradient of the input.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_grad</span></code>(func[, inputs, test_inputs, eps, …])</p></td>
<td><p>Perform numerical gradient checking given a relay function.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">count_ops</span></code>(expr)</p></td>
<td><p>count number of times a given op is called in the graph</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">Prelude</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude" title="永久链接至目标">¶</a></dt>
<dd><p>Contains standard definitions.</p>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_name</span></code>(canonical, dtype)</p></td>
<td><p>Get name corresponding to the canonical name</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_global_var</span></code>(canonical, dtype)</p></td>
<td><p>Get global var corresponding to the canonical name</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_type</span></code>(canonical, dtype)</p></td>
<td><p>Get type corresponding to the canonical name</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_ctor</span></code>(ty_name, canonical, dtype)</p></td>
<td><p>Get constructor corresponding to the canonical name</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_name_static</span></code>(canonical, dtype, shape[, …])</p></td>
<td><p>Get name corresponding to the canonical name</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_global_var_static</span></code>(canonical, dtype, shape)</p></td>
<td><p>Get var corresponding to the canonical name</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_type_static</span></code>(canonical, dtype, shape)</p></td>
<td><p>Get type corresponding to the canonical name</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_ctor_static</span></code>(ty_name, name, dtype, shape)</p></td>
<td><p>Get constructor corresponding to the canonical name</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_tensor_ctor_static</span></code>(name, dtype, shape)</p></td>
<td><p>Get constructor corresponding to the canonical name</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_prelude</span></code>()</p></td>
<td><p>Parses the Prelude from Relay’s text format into a module.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_name">
<span class="sig-name descname"><span class="pre">get_name</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">canonical</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_name" title="永久链接至目标">¶</a></dt>
<dd><p>Get name corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_global_var">
<span class="sig-name descname"><span class="pre">get_global_var</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">canonical</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_global_var" title="永久链接至目标">¶</a></dt>
<dd><p>Get global var corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_type">
<span class="sig-name descname"><span class="pre">get_type</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">canonical</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_type" title="永久链接至目标">¶</a></dt>
<dd><p>Get type corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_ctor">
<span class="sig-name descname"><span class="pre">get_ctor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ty_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">canonical</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_ctor" title="永久链接至目标">¶</a></dt>
<dd><p>Get constructor corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_name_static">
<span class="sig-name descname"><span class="pre">get_name_static</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">canonical</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_name_static" title="永久链接至目标">¶</a></dt>
<dd><p>Get name corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_global_var_static">
<span class="sig-name descname"><span class="pre">get_global_var_static</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">canonical</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_global_var_static" title="永久链接至目标">¶</a></dt>
<dd><p>Get var corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_type_static">
<span class="sig-name descname"><span class="pre">get_type_static</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">canonical</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_type_static" title="永久链接至目标">¶</a></dt>
<dd><p>Get type corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_ctor_static">
<span class="sig-name descname"><span class="pre">get_ctor_static</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ty_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_ctor_static" title="永久链接至目标">¶</a></dt>
<dd><p>Get constructor corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.get_tensor_ctor_static">
<span class="sig-name descname"><span class="pre">get_tensor_ctor_static</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.get_tensor_ctor_static" title="永久链接至目标">¶</a></dt>
<dd><p>Get constructor corresponding to the canonical name</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.testing.Prelude.load_prelude">
<span class="sig-name descname"><span class="pre">load_prelude</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.Prelude.load_prelude" title="永久链接至目标">¶</a></dt>
<dd><p>Parses the Prelude from Relay’s text format into a module.</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.enabled_targets">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">enabled_targets</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.enabled_targets" title="永久链接至目标">¶</a></dt>
<dd><p>Get all enabled targets with associated devices.</p>
<p>In most cases, you should use <code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.testing.parametrize_targets()</span></code> instead of
this function.</p>
<p>In this context, enabled means that TVM was built with support for
this target, the target name appears in the TVM_TEST_TARGETS
environment variable, and a suitable device for running this
target exists.  If TVM_TEST_TARGETS is not set, it defaults to
variable DEFAULT_TEST_TARGETS in this module.</p>
<p>If you use this function in a test, you <strong>must</strong> decorate the test with
<code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.testing.uses_gpu()</span></code> (otherwise it will never be run on the gpu).</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>targets</strong> – A list of pairs of all enabled devices and the associated context</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)">list</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.create_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">create_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">net</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">initializer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.create_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Helper function to create benchmark image classification workload.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>net</strong> (<em>tvm.relay.Function</em>) – The selected function of the network.</p></li>
<li><p><strong>initializer</strong> (<em>Initializer</em>) – The initializer used</p></li>
<li><p><strong>seed</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The seed used in initialization.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The created relay module.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.count">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">count</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prelude</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.count" title="永久链接至目标">¶</a></dt>
<dd><p>Takes a ConstructorValue corresponding to a nat ADT
and converts it into a Python integer. This is an example of
using an ADT value in Python.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.make_nat_value">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">make_nat_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prelude</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.make_nat_value" title="永久链接至目标">¶</a></dt>
<dd><p>The inverse of count(): Given a non-negative Python integer,
constructs a ConstructorValue representing that value as a nat.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.make_nat_expr">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">make_nat_expr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prelude</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.make_nat_expr" title="永久链接至目标">¶</a></dt>
<dd><p>Given a non-negative Python integer, constructs a Python
expression representing that integer’s value as a nat.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.to_python">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">to_python</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="pre">expr:</span> <span class="pre">tvm.ir.expr.RelayExpr</span></em>, <em class="sig-param"><span class="pre">mod=None</span></em>, <em class="sig-param"><span class="pre">target=llvm</span> <span class="pre">-keys=cpu</span> <span class="pre">-link-params=0</span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.to_python" title="永久链接至目标">¶</a></dt>
<dd><p>Converts the given Relay expression into a Python script (as a Python AST object).
For easiest debugging, import the astor package and use to_source().</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.run_as_python">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">run_as_python</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="pre">expr:</span> <span class="pre">tvm.ir.expr.RelayExpr</span></em>, <em class="sig-param"><span class="pre">mod=None</span></em>, <em class="sig-param"><span class="pre">target=llvm</span> <span class="pre">-keys=cpu</span> <span class="pre">-link-params=0</span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.run_as_python" title="永久链接至目标">¶</a></dt>
<dd><p>Converts the given Relay expression into a Python script and
executes it.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.gradient">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">gradient</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'higher_order'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.gradient" title="永久链接至目标">¶</a></dt>
<dd><p>Transform the input function,
returning a function that calculate the original result,
paired with gradient of the input.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression, which is a Function or a GlobalVar.</p></li>
<li><p><strong>mod</strong> (<em>Optional</em><em>[</em><em>tvm.IRModule</em><em>]</em>) – </p></li>
<li><p><strong>mode</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String"><em>String</em></a><em>]</em>) – The mode of the automatic differentiation algorithm.
‘first_order’ only works on first order code, but will not produce
reference nor closure.
‘higher_order’ works on all code using reference and closure.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>expr</strong> – The transformed expression.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.relay.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.check_grad">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">check_grad</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inputs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">test_inputs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-06</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">atol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rtol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.001</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mean</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'higher_order'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_devices</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.check_grad" title="永久链接至目标">¶</a></dt>
<dd><p>Perform numerical gradient checking given a relay function.</p>
<p>Compare analytical gradients to numerical gradients derived from two-sided approximation. Note
that this test may fail if your function input types are not of high enough precision.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<em>tvm.relay.Function</em>) – The relay function to test.</p></li>
<li><p><strong>inputs</strong> (<a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>np.array</em><em>]</em>) – Optional user-provided input parameters to use. If not given, will generate random normal
inputs scaled to be close to the chosen epsilon value to avoid numerical precision loss.</p></li>
<li><p><strong>test_inputs</strong> (<a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>np.array</em><em>]</em>) – The inputs to test for gradient matching. Useful in cases where some inputs are not
differentiable, such as symbolic inputs to dynamic ops. If not given, all inputs are
tested.</p></li>
<li><p><strong>eps</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The epsilon value to use for computing numerical gradient approximation.</p></li>
<li><p><strong>atol</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The absolute tolerance on difference between numerical and analytical gradients. Note that
this needs to be scaled appropriately relative to the chosen eps and inputs.</p></li>
<li><p><strong>rtol</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The relative tolerance on difference between numerical and analytical gradients. Note that
this needs to be scaled appropriately relative to the chosen eps.</p></li>
<li><p><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The standard deviation of the inputs.</p></li>
<li><p><strong>mean</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The mean of the inputs.</p></li>
<li><p><strong>target_devices</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>Tuple</em><em>[</em><a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a><em>, </em><a class="reference internal" href="../runtime.html#tvm.runtime.Device" title="tvm.runtime.Device"><em>tvm.runtime.Device</em></a><em>]</em><em>]</em><em>]</em>) – A list of targets/devices on which the gradient should be
tested.  If not specified, will default to <cite>tvm.testing.enabled_targets()</cite>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.count_ops">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.</span></span><span class="sig-name descname"><span class="pre">count_ops</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.count_ops" title="永久链接至目标">¶</a></dt>
<dd><p>count number of times a given op is called in the graph</p>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.mlp"></span><p>a simple multilayer perceptron</p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.mlp.get_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.mlp.</span></span><span class="sig-name descname"><span class="pre">get_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">28,</span> <span class="pre">28)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.mlp.get_net" title="永久链接至目标">¶</a></dt>
<dd><p>Get network a simple multilayer perceptron.</p>
<dl class="simple">
<dt>batch_size<span class="classifier">int</span></dt><dd><p>The batch size used in the model</p>
</dd>
<dt>num_classes<span class="classifier">int, optional</span></dt><dd><p>Number of claseses</p>
</dd>
<dt>image_shape<span class="classifier">tuple, optional</span></dt><dd><p>The input image shape</p>
</dd>
<dt>dtype<span class="classifier">str, optional</span></dt><dd><p>The data type</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>net</strong> – The dataflow.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>relay.Function</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.mlp.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.mlp.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">28,</span> <span class="pre">28)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.mlp.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for a simple multilayer perceptron.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of claseses</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a mlp network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.resnet"></span><p>Adapted from <a class="reference external" href="https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py">https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py</a>
Original author Wei Wu</p>
<p>Implemented the following paper:</p>
<p>Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. “Identity Mappings in Deep Residual Networks”</p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.resnet.residual_unit">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.resnet.</span></span><span class="sig-name descname"><span class="pre">residual_unit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_filter</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stride</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim_match</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bottle_neck</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kernel_layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'IOHW'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.resnet.residual_unit" title="永久链接至目标">¶</a></dt>
<dd><p>Return ResNet Unit symbol for building ResNet</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – Input data</p></li>
<li><p><strong>num_filter</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Number of output channels</p></li>
<li><p><strong>bnf</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Bottle neck channels factor with regard to num_filter</p></li>
<li><p><strong>stride</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a>) – Stride used in convolution</p></li>
<li><p><strong>dim_match</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – True means channel number between input and output is the same,
otherwise means differ</p></li>
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – Base name of the operators</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.resnet.resnet">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.resnet.</span></span><span class="sig-name descname"><span class="pre">resnet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">units</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_stages</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filter_list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bottle_neck</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.resnet.resnet" title="永久链接至目标">¶</a></dt>
<dd><p>Return ResNet Program.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>units</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – Number of units in each stage</p></li>
<li><p><strong>num_stages</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Number of stages</p></li>
<li><p><strong>filter_list</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a>) – Channel size of each stage</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Output size of symbol</p></li>
<li><p><strong>data_shape</strong> (<em>tuple of int.</em>) – The shape of input data.</p></li>
<li><p><strong>bottle_neck</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether apply bottleneck transformation.</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data layout for conv2d</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The global data type.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.resnet.get_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.resnet.</span></span><span class="sig-name descname"><span class="pre">get_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_layers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">50</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">224,</span> <span class="pre">224)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.resnet.get_net" title="永久链接至目标">¶</a></dt>
<dd><p>Adapted from <a class="reference external" href="https://github.com/tornadomeet/ResNet/blob/master/train_resnet.py">https://github.com/tornadomeet/ResNet/blob/master/train_resnet.py</a>
Original author Wei Wu</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.resnet.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.resnet.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_layers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">18</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">224,</span> <span class="pre">224)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.resnet.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for resnet</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of classes</p></li>
<li><p><strong>num_layers</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of layers</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The data layout for conv2d</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
<li><p><strong>kwargs</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(在 Python v3.10)"><em>dict</em></a>) – Extra arguments</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a ResNet network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.dcgan"></span><p>Net of the generator of DCGAN</p>
<p>Adopted from:
<a class="reference external" href="https://github.com/tqchen/mxnet-gan/blob/main/mxgan/generator.py">https://github.com/tqchen/mxnet-gan/blob/main/mxgan/generator.py</a></p>
<p>Reference:
Radford, Alec, Luke Metz, and Soumith Chintala.
“Unsupervised representation learning with deep convolutional generative adversarial networks.”
arXiv preprint arXiv:1511.06434 (2015).</p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.dcgan.deconv2d">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.dcgan.</span></span><span class="sig-name descname"><span class="pre">deconv2d</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ishape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">oshape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kshape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stride</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(2,</span> <span class="pre">2)</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.dcgan.deconv2d" title="永久链接至目标">¶</a></dt>
<dd><p>a deconv layer that enlarges the feature map</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.dcgan.deconv2d_bn_relu">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.dcgan.</span></span><span class="sig-name descname"><span class="pre">deconv2d_bn_relu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prefix</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.dcgan.deconv2d_bn_relu" title="永久链接至目标">¶</a></dt>
<dd><p>a block of deconv + batch norm + relu</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.dcgan.get_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.dcgan.</span></span><span class="sig-name descname"><span class="pre">get_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_len</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">oshape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">64,</span> <span class="pre">64)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ngf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">128</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">code</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.dcgan.get_net" title="永久链接至目标">¶</a></dt>
<dd><p>get net of dcgan generator</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.dcgan.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.dcgan.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">oshape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">64,</span> <span class="pre">64)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ngf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">128</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_len</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.dcgan.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for a DCGAN generator</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>oshape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The shape of output image, layout=”CHW”</p></li>
<li><p><strong>ngf</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The number of final feature maps in the generator</p></li>
<li><p><strong>random_len</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The length of random input</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The layout of conv2d transpose</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a DCGAN network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.mobilenet"></span><p>Port of NNVM version of MobileNet to Relay.</p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.mobilenet.conv_block">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.mobilenet.</span></span><span class="sig-name descname"><span class="pre">conv_block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">channels</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kernel_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">3)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strides</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">padding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">epsilon</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.mobilenet.conv_block" title="永久链接至目标">¶</a></dt>
<dd><p>Helper function to construct conv_bn-relu</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.mobilenet.separable_conv_block">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.mobilenet.</span></span><span class="sig-name descname"><span class="pre">separable_conv_block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">depthwise_channels</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pointwise_channels</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kernel_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">3)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">downsample</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">padding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">epsilon</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.mobilenet.separable_conv_block" title="永久链接至目标">¶</a></dt>
<dd><p>Helper function to get a separable conv block</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.mobilenet.mobile_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.mobilenet.</span></span><span class="sig-name descname"><span class="pre">mobile_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">3,</span> <span class="pre">224,</span> <span class="pre">224)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">is_shallow</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.mobilenet.mobile_net" title="永久链接至目标">¶</a></dt>
<dd><p>Function to construct a MobileNet</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.mobilenet.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.mobilenet.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">224,</span> <span class="pre">224)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.mobilenet.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for mobilenet</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The batch size used in the model</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of classes</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape, cooperate with layout</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data layout of image_shape and the operators
cooperate with image_shape</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a MobileNet network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.lstm"></span><p>Implementation of a Long Short-Term Memory (LSTM) cell.</p>
<p>Adapted from:
<a class="reference external" href="https://gist.github.com/merrymercy/5eb24e3b019f84200645bd001e9caae9">https://gist.github.com/merrymercy/5eb24e3b019f84200645bd001e9caae9</a></p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.lstm.lstm_cell">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.lstm.</span></span><span class="sig-name descname"><span class="pre">lstm_cell</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num_hidden</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.lstm.lstm_cell" title="永久链接至目标">¶</a></dt>
<dd><p>Long-Short Term Memory (LSTM) network cell.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>num_hidden</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Number of units in output symbol.</p></li>
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Batch size (length of states).</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – A Relay function that evaluates an LSTM cell.
The function takes in a tensor of input data, a tuple of two
states, and weights and biases for dense operations on the
inputs and on the state. It returns a tuple with two members,
an output tensor and a tuple of two new states.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.relay.Function</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.lstm.get_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.lstm.</span></span><span class="sig-name descname"><span class="pre">get_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">iterations</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_hidden</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.lstm.get_net" title="永久链接至目标">¶</a></dt>
<dd><p>Constructs an unrolled RNN with LSTM cells</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.lstm.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.lstm.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">iterations</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_hidden</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.lstm.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for an LSTM RNN.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>iterations</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The number of iterations in the desired LSTM RNN.</p></li>
<li><p><strong>num_hidden</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The size of the hiddxen state</p></li>
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em><em> (</em><em>default 1</em><em>)</em>) – The batch size used in the model</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em><em> (</em><em>default &quot;float32&quot;</em><em>)</em>) – The data type</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a LSTM network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.inception_v3"></span><p>Inception V3, suitable for images with around 299 x 299</p>
<p>Reference:
Szegedy, Christian, et al. “Rethinking the Inception Architecture for Computer Vision.”
arXiv preprint arXiv:1512.00567 (2015).</p>
<dl class="simple">
<dt>Adopted from <a class="reference external" href="https://github.com/apache/incubator-mxnet/blob/">https://github.com/apache/incubator-mxnet/blob/</a></dt><dd><p>master/example/image-classification/symbols/inception-v3.py</p>
</dd>
</dl>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.inception_v3.get_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.inception_v3.</span></span><span class="sig-name descname"><span class="pre">get_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.inception_v3.get_net" title="永久链接至目标">¶</a></dt>
<dd><p>Get network a Inception v3 network.</p>
<dl class="simple">
<dt>batch_size<span class="classifier">int</span></dt><dd><p>The batch size used in the model</p>
</dd>
<dt>num_classes<span class="classifier">int, optional</span></dt><dd><p>Number of claseses</p>
</dd>
<dt>image_shape<span class="classifier">tuple, optional</span></dt><dd><p>The input image shape</p>
</dd>
<dt>dtype<span class="classifier">str, optional</span></dt><dd><p>The data type</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>net</strong> – The dataflow.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>relay.Function</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.inception_v3.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.inception_v3.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">299,</span> <span class="pre">299)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.inception_v3.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for InceptionV3</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of classes</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains an Inception V3 network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.squeezenet"></span><p>Symbol of SqueezeNet</p>
<p>Reference:
Iandola, Forrest N., et al.
“Squeezenet: Alexnet-level accuracy with 50x fewer parameters and&lt; 0.5 mb model size.” (2016).</p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.squeezenet.get_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.squeezenet.</span></span><span class="sig-name descname"><span class="pre">get_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">version</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.squeezenet.get_net" title="永久链接至目标">¶</a></dt>
<dd><p>Get symbol of SqueezeNet</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The number of classification results</p></li>
<li><p><strong>version</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – “1.0” or “1.1” of SqueezeNet</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.squeezenet.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.squeezenet.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">version</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'1.0'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">224,</span> <span class="pre">224)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.squeezenet.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for SqueezeNet</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of classes</p></li>
<li><p><strong>version</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – “1.0” or “1.1” of SqueezeNet</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a SqueezeNet network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.vgg"></span><p>References:</p>
<p>Simonyan, Karen, and Andrew Zisserman. “Very deep convolutional networks for
large-scale image recognition.” arXiv preprint arXiv:1409.1556 (2014).</p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.vgg.get_feature">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.vgg.</span></span><span class="sig-name descname"><span class="pre">get_feature</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">internal_layer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layers</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filters</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_norm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.vgg.get_feature" title="永久链接至目标">¶</a></dt>
<dd><p>Get VGG feature body as stacks of convolutions.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.vgg.get_classifier">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.vgg.</span></span><span class="sig-name descname"><span class="pre">get_classifier</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.vgg.get_classifier" title="永久链接至目标">¶</a></dt>
<dd><p>Get VGG classifier layers as fc layers.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.vgg.get_net">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.vgg.</span></span><span class="sig-name descname"><span class="pre">get_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_layers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">11</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_norm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.vgg.get_net" title="永久链接至目标">¶</a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of claseses</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
<li><p><strong>num_layers</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Number of layers for the variant of vgg. Options are 11, 13, 16, 19.</p></li>
<li><p><strong>batch_norm</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a><em>, </em><em>default False</em>) – Use batch normalization.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.vgg.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.vgg.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">batch_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">224,</span> <span class="pre">224)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_layers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">11</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_norm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.vgg.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Get benchmark workload for VGG nets.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The batch size used in the model</p></li>
<li><p><strong>num_classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Number of claseses</p></li>
<li><p><strong>image_shape</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a><em>, </em><em>optional</em>) – The input image shape</p></li>
<li><p><strong>dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The data type</p></li>
<li><p><strong>num_layers</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Number of layers for the variant of vgg. Options are 11, 13, 16, 19.</p></li>
<li><p><strong>batch_norm</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Use batch normalization.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a VGG network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.testing.densenet"></span><p>Port of MxNet version of Densenet to Relay.
<a class="reference external" href="https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/gluon/model_zoo/vision/densenet.py">https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/gluon/model_zoo/vision/densenet.py</a></p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.testing.densenet.get_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.testing.densenet.</span></span><span class="sig-name descname"><span class="pre">get_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">densenet_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">121</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">classes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(3,</span> <span class="pre">224,</span> <span class="pre">224)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'float32'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.testing.densenet.get_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Gets benchmark workload for densenet.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>densenet_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em><em> (</em><em>default 121</em><em>)</em>) – Parameter for the network size. The supported sizes
are 121, 161, 169, and 201.</p></li>
<li><p><strong>classes</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em><em> (</em><em>default 1000</em><em>)</em>) – The number of classes.</p></li>
<li><p><strong>batch_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em><em> (</em><em>detault 4</em><em>)</em>) – The batch size for the network.</p></li>
<li><p><strong>image_shape</strong> (<em>shape</em><em>, </em><em>optional</em><em> (</em><em>default</em><em> (</em><em>3</em><em>, </em><em>224</em><em>, </em><em>224</em><em>)</em><em>)</em>) – The shape of the input data.</p></li>
<li><p><strong>dtype</strong> (<em>data type</em><em>, </em><em>optional</em><em> (</em><em>default 'float32'</em><em>)</em>) – The data type of the input data.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The relay module that contains a DenseNet network.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – The benchmark paraeters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../autotvm.html" class="btn btn-neutral float-right" title="tvm.autotvm" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="dataflow_pattern.html" class="btn btn-neutral float-left" title="tvm.relay.dataflow_pattern" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>